<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>

<body>
<?php  include 'action/session_check.php'; //登录判断  ?>  
<form action="action/product_update_do.php" method="post"  enctype="multipart/form-data">
<?php   
 if($_GET["p_id"] != "" )
 {
   require_once("../conn/conn_db.php");  //包含数据库连接文件  
   $pid= $_GET["p_id"];    //获取传递的商品编号 
   $sql = "select * from product_info where p_id=".$pid; //查询语句
   $result = $conn->query($sql);                 //执行SQL语句
   //遍历查询结果的每一行
   if ($result->num_rows > 0) {
       $row = $result->fetch_assoc(); 
   $parentid2 = $row['pt_id'];  //将类别编号赋值给变量$parentid2,用于定位所属类别下拉框的选中项
?>
<table>
  <tr><td colspan="2">编辑商品信息</td></tr>
  <tr>
     <td><font color="red">*</font>所属类别</td>
     <td><?php include 'select_producttype3.php';?></td>
  </tr>
  <tr>
     <td><font color="red">*</font>商品名称：</td>
     <td><input type="text" name="txt_name" value="<?php echo $row['p_name'] ?>"/></td>
  </tr>
  <tr>
     <td><font color="red">*</font>商品图片：</td>
     <td><input type="file" name="txt_image"/></td>
  </tr>
  <tr>
     <td><font color="red">*</font>价格：</td>
     <td><input type="text" name="txt_price" value="<?php echo $row['p_price'] ?>"/></td>
  </tr>
  <tr>
     <td>品牌：</td>
     <td><input type="text" name="txt_brand" value="<?php echo $row['p_brand'] ?>"/></td>
  </tr>
  <tr>
     <td>商品介绍：</td>
     <td>
      <textarea id="txt_intro" name="txt_intro" rows="8" cols="47"><?php echo $row['p_intro'] ?></textarea>
      <img src='../<?php echo $row["p_image"];?>' width="130" height="130"/>
      <input type="hidden" name="txt_image2"  value='<?php echo $row["p_image"];?>'/>
     </td>
  </tr>
  <tr>
     <td colspan="2">
       <input type="hidden" name="txt_id" value="<?php echo $row['p_id'] ?>"/>
       <input type="submit" value="保存" />
       <input type="button" value="返回" onClick="javascript:history.back();" />
     </td>
  </tr>
    <tr>
    <td colspan="2"></td>
  </tr> 
</table>
<?php 
 }
 }
 else 
 {
   echo "<script>alert('请选择要编辑的商品信息！');self.location='product_manager.php'</script>";     
 }
 ?>
</form>
</body>
</html>